<?php
/**
 * Created by PhpStorm.
 * User: zsd
 * Date: 2018/4/27
 * Time: 下午4:00
 */
namespace common\controllers;

use common\behaviors\ApiAuthBehaviors;
use yii\rest\Controller;
use yii\web\Response;

class BaseController extends Controller
{

    public function behaviors()
    {
        $behaviors = parent::behaviors();

        $behaviors['contentNegotiator']['formats'] = ['application/json' => Response::FORMAT_JSON];
        $behaviors['authenticator']['authMethods'] = [
            'class' => ApiAuthBehaviors::class,
        ];

        $behaviors['access'] = [
            'class' => 'common\components\rbac\AccessControl',
            'allowActions' => [
                'site/error',
                //FIXME
                'admin/*',
                'user/*',
            ]
        ];

        return $behaviors;
    }
}
